--[[ UNIT - Serpent Shrine Cavern - Generic.lua

********************************
*                                                            *
* The Moon++ Scripting Project        *
*                                                            *
********************************

This software is provided as free and open source by the
staff of The Moon++ Scripting Project, in accordance with 
the GPL license. This means we provide the software we have 
created freely and it has been thoroughly tested to work for 
the developers, but NO GUARANTEE is made it will work for you 
as well. Please give credit where credit is due, if modifying,
redistributing and/or using this software. Thank you.

Staff of The Moon++ Scripting Project, November 2007
~~End of License Agreement

All credits for the files in this folder that are GameMonkey scripts
go to the GMScripts project, for all their hard work for the Ascent 
community.

-- Moon++ Project, November 2007 ]]

--  [[ Coilfang Ambusher ]] --

function CoilfangAmbush_Multishot(unit)
local plr = unit:GetRandomPlayer(0)
if (plr ~= nil) then
unit:FullCastSpellOnTarget(27021,plr)
end
end

function CoilfangAmbush_OnEnterCombat(unit)
unit:RegisterEvent("CoilfangAmbush_Multishot",4500,99)
end
RegisterUnitEvent(21865, 1, "CoilfangAmbush_OnEnterCombat")

-- [[ Coilfang Fathom Witch ]] --

function CoilWitch_ShadowBolt(Unit)
local plr = unit:GetClosestPlayer()
if (plr ~= null) then
   unit:FullCastSpellOnTarget(27209,plr)
end
end

function CoilWitch_Knockback(unit)
local plr = unit:GetRandomPlayer(1)
if (plr ~= nil) then
unit:FullCastSpellOnTarget(34109,plr)
end
end

function CoilWitch_OnEnterCombat(unit)
unit:RegisterEvent("CoilWitch_ShadowBolt",15000,99)
unit:RegisterEvent("CoilWitch_Knockback",60000,99)
end

RegisterUnitEvent(21299, 1, "CoilWitch_OnEnterCombat")

-- [[ CoilFang Guardian ]] -- 

function CoilGuard_Cleave(unit)
unit:FullCastSpellOnTarget(38260,unit:GetClosestPlayer())
end

function CoilGuard_OnEnterCombat(unit)
unit:RegisterEvent("CoilGuard_Cleave",40000,99)
end
RegisterUnitEvent(21873, 1, "CoilGuard_OnEnterCombat")

-- [[ Coilfang Priestess ]] --

function CoilPriest_Holynova(unit)
local plr = unit:GetRandomPlayer(0)
if (plr ~= null) then
   unit:FullCastSpellOnTarget(38589,plr)
end
end

function CoilPriest_Smite(unit)
unit:FullCastSpellOnTarget(25364,unit:GetClosestPlayer())
end

function CoilPriest_OnEnterCombat(unit)
unit:RegisterEvent("CoilPriest_Holynova",35000,10)
unit:RegisterEvent("CoilPriest_Smite",5000,0)
end

RegisterUnitEvent(21220, 1, "CoilPriest_OnEnterCombat")


-- [[ Coilfang Serpent Guard ]] --
function CoilSert_SpellReflect(unit)
unit:FullCastSpell(36096)
end

function CoilSert_Cleave(unit)
unit:FullCastSpellOnTarget(38260,unit:GetClosestPlayer())
end

function CoilSert_OnEnterCombat(unit)
unit:RegisterEvent("CoilSert_SpellReflect",15000,10)
unit:RegisterEvent("CoilSert_Cleave",30000,0)
end

RegisterUnitEvent(21298, 1, "CoilSert_OnEnterCombat")

-- [[ Coilfang Shatterer ]] --

function CoilShat_ShatterArmor(unit)
unit:FullCastSpellOnTarget(38591,unit:GetClosestPlayer())
end

function CoilShat_OnEnterCombat(unit)
unit:RegisterEvent("CoilShat_ShatterArmor",30000,0)
end

RegisterUnitEvent(21301, 1, "CoilShat_OnEnterCombat")

-- [[ Coilfang Strider ]] --

function CoilStride_PsychicScream(unit)
unit:FullCastSpell(36096)
end

function CoilStride_OnEnterCombat(unit)
unit:RegisterEvent("CoilStride_PsychicScream",40000,2)
end 

RegisterUnitEvent(22056, 1, "CoilStride_OnEnterCombat")

-- [[ Fathom Guard Caribdis ]] --

function FathGuardCarb_WaterBolt(unit)
unit:FullCastSpellOnTarget(38335,unit:GetClosestPlayer())
end

function FathGuardCarb_Heal(unit)
Unit:FullCastSpell(6064)
end

function FathGuardCarb_OnEnterCombat(unit)
unit:RegisterEvent("FathGuardCarb_Heal",10000,0)
unit:RegisterEvent("FathGuardCarb_WaterBolt",40000,0)
end

RegisterUnitEvent(21964, 1, "FathGuardCarb_OnEnterCombat")

-- [[ Fathom Guard Sharkkis ]] --

function FathGuardShark_Multishot(unit)
unit:FullCastSpellOnTarget(27021,unit:GetClosestPlayer())
end

function FathGuardShark_Vipersting(unit)
unit:FullCastSpellOnTarget(37551,unit:GetClosestPlayer())
end

function FathGuardShark_OnEnterCombat(unit)
FathGuardSharkSpawn = math.random(1, 2)
if (FathGuardSharkSpawn==1) then
x=unit:GetX();
y=unit:GetY();
z=unit:GetZ();
unit:SpawnCreature(21260, x, y, z, 0, 14, 360000);
end
if (FathGuardSharkSpawn==2) then
x=unit:GetX();
y=unit:GetY();
z=unit:GetZ();
unit:SpawnCreature(21246, x, y, z, 0, 14, 360000);
end
unit:RegisterEvent("FathGuardShark_Multishot",8000,0)
unit:RegisterEvent("FathGuardShark_Vipersting",20000,0)
end
function FathGuardShark_OnLeaveCombat(unit)
unit:Despawn(1000, 0);
-- unit:RemoveEvents()
end

RegisterUnitEvent(21966, 1, "FathGuardShark_OnEnterCombat")
RegisterUnitEvent(21966, 2, "FathGuardShark_OLeaveCombat")

-- [[ Fathom Guard Tidalves ]] --

function FathGuardTidal_Spitfire(unit)
unit:FullCastSpell(38236)
end

function FathGuardTidal_Cleansing(unit)
unit:FullCastSpell(8170)
end

function FathGuardTidal_Earthbind(unit)
unit:FullCastSpell(2484)
end

function FathGuardTidal_OnEnterCombat(unit)
unit:RegisterEvent("FathGuardTidal_Earthbind",20000,0)
unit:RegisterEvent("FathGuardTidal_Spitfire",50000,0)
unit:RegisterEvent("FathGuardTidal_Cleansing",30000,0)
end
RegisterUnitEvent(21965, 1, "FathGuardTidal_OnEnterCombat")

-- [[ GreyHeart Nether Mage ]] --

function GreyNetherMage_RainFire(unit)
local plr = unit:GetRandomPlayer(0)
if (plr ~= nil) then
unit:FullCastSpellOnTarget(27212,plr)
end
end

function GreyNetherMage_Fireball(unit)
unit:FullCastSpellOnTarget(38836,unit:GetClosestPlayer())
end

function GreyNetherMage_ConeOfCold(unit)
unit:FullCastSpellOnTarget(27087,unit:GetClosestPlayer())
end

function GreyNetherMage_Frostbolt(unit)
unit:FullCastSpellOnTarget(37262,unit:GetClosestPlayer())
end

function GreyNetherMage_Lightning(unit)
unit:FullCastSpellOnTarget(38146,unit:GetClosestPlayer())
end

function GreyNetherMage_OnEnterCombat(unit)
unit:RegisterEvent("GreyNetherMage_RainFire",10000,1)
unit:RegisterEvent("GreyNetherMage_Fireball",20000,1)
unit:RegisterEvent("GreyNetherMage_ConeOfCold",30000,3)
unit:RegisterEvent("GreyNetherMage_Frostbolt",40000,3)
unit:RegisterEvent("GreyNetherMage_Lightning",50000,3)
end
RegisterUnitEvent(21230, 1, "GreyNetherMage_OnEnterCombat")

-- [[ Greyheart Shield Bearer ]]--

function GreyShieldBearer_AvengerShield(unit)
unit:FullCastSpellOnTarget(32700,unit:GetClosestPlayer())
end

function GreyShieldBearer_Charge(unit)
unit:FullCastSpellOnTarget(11578,unit:GetClosestPlayer())
end

function GreyShieldBearer_OnEnterCombat(unit)
unit:RegisterEvent("GreyShieldBearer_AvengerShield",20000,0)
unit:RegisterEvent("GreyShieldBearer_Charge",1000,0)
end
RegisterUnitEvent(21231, 1, "GreyShieldBearer_OnEnterCombat")